Implementation of Hypothetical-Set Aggregate Functions#9035
Open
sim1984 wants to merge 3 commits into
Open
Conversation
Contributor
Author
|
This PR completely closes the issue #7632 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hypothetical-Set Aggregate Functions
Hypothetical set functions include ranking and rank distribution functions, which you are already familiar with as window functions, but they are applied to groups to enter values in hypothetical form.
There are two sorted set ranking functions:
RANKandDENSE_RANK. There are also two sorted set rank distribution functions:PERCENT_RANKandCUME_DIST. Window functions and ordered set functions differ in the way they order. The former order within a window, while the latter order within a group.Syntax of aggregate functions of a hypothetical set:
Each of the "hypothetical-set" aggregates is associated with a window function of the same name. In each case, the aggregate's result is the value that the associated window function would have returned for the "hypothetical" row constructed from
args, if such a row had been added to the sorted group of rows represented by thesorted_args. For each of these functions, the list of direct arguments given inargsmust match the number and types of the aggregated arguments given insorted_args. Unlike most built-in aggregates, these aggregates are not strict, that is they do not drop input rows containing NULLs.NULLvalues sort according to the rule specified in theORDER BYclause.The values of the input arguments
argsmust be constant within each group.An example of using hypothetical set functions without grouping:
An example of using hypothetical set functions with grouping:
An example of using hypothetical functions with two arguments: